package com.project.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.project.bean.NoteBean;
import com.project.mapper.INoteMapper;
import com.project.service.INoteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDate;

@Service
public class NoteServiceImp implements INoteService {
    @Autowired
    private INoteMapper mapper;

    @Override
    public PageInfo<NoteBean> findAll(int PageNO) {
        PageHelper.startPage(PageNO, PAGESIZE);
        PageInfo<NoteBean> pageInfo=PageInfo.of(mapper.findByItem(null, null));
        return pageInfo;
    }

    @Override
    public PageInfo<NoteBean> findByItem(int PageNO, LocalDate startDate, LocalDate endDate) {
        PageHelper.startPage(PageNO, PAGESIZE);
        PageInfo<NoteBean> pageInfo=PageInfo.of(mapper.findByItem(startDate, endDate));
        return pageInfo;
    }

    @Override
    public void addNote(NoteBean note) {
        mapper.add(note);
    }
}
